// videoApi.js - 视频相关接口
import request from './request.js';

const videoApi = {
    // 获取视频列表
    getVideoList(params) {
        return request({
            url: '/api/videos',
            method: 'get',
            params
        });
    },

    // 获取视频详情
    getVideoDetail(id) {
        return request({
            url: `/api/videos/${id}`,
            method: 'get'
        });
    },

    // 上传视频
    uploadVideo(formData) {
        return request({
            url: '/api/videos/upload',
            method: 'post',
            data: formData,
            headers: {
                'Content-Type': 'multipart/form-data'
            }
        });
    },

    // 获取视频弹幕
    getDanmaku(videoId) {
        return request({
            url: `/api/videos/${videoId}/danmaku`,
            method: 'get'
        });
    },

    // 发送弹幕
    sendDanmaku(videoId, data) {
        return request({
            url: `/api/videos/${videoId}/danmaku`,
            method: 'post',
            data
        });
    },

    // 获取视频评论
    getComments(videoId) {
        return request({
            url: `/api/videos/${videoId}/comments`,
            method: 'get'
        });
    },

    // 发表评论
    postComment(videoId, data) {
        return request({
            url: `/api/videos/${videoId}/comments`,
            method: 'post',
            data
        });
    }
};

export default videoApi;
